<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="../../include.inc.jsp"%>
<link rel="stylesheet" type="text/css" href="${contextPath}/static/assets/css/bootstrap-datepicker3.css" />
<div class="row">
    <div class="col-lg-12">
        <form id="formDlg" class="form-horizontal" role="form">
            <input type="hidden" id="id" name="id" value="${userInfo.id}" />
            <input type="hidden" id="id" name="user.id" value="${userInfo.user.id}" />
            <!-- 数据权限 -->
            <input type="hidden" id="organizationId" name="organization.id" value="${organizationId}" /> 
            <div class="form-group">
                <label class="col-lg-2 control-label">所属病房:</label><span class="text-danger">*</span>
                <div class="col-lg-9">
                    <input type="hidden" class="form-control" id="wardId" name="ward.id" value="${userInfo.ward.id}" />
                    <input type="text" readonly="readonly" class="form-control" id="wardName" name="wardName" value="${userInfo.ward.name}" onclick="selectWard();"/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-lg-2 control-label">手机号:</label><span class="text-danger">*</span>
                <div class="col-lg-9">
                    <input type="text" class="form-control" id="mobile" name="user.mobile" value="${userInfo.user.mobile}" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-lg-2 control-label">姓名:</label>
                <div class="col-lg-9">
                    <input type="text" class="form-control" id="name" name="name" maxlength="30" value="${userInfo.name}" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-lg-2 control-label">性别:</label>
                <div class="col-lg-9">
                    <x:dictData dictCode="Sex_Type" var="sexTypes">
                        <x:select var="sex" items="${sexTypes}" id="sex" name="sex" className="form-control">
                            <x:option value="${sex.code }" text="${sex.name }" selected="${userInfo.sex eq sex.code}"></x:option>
                        </x:select>
                    </x:dictData>
                </div>
            </div>
            <div class="form-group">
                <label class="col-lg-2 control-label">生日:</label>
                <div class="col-lg-9">
                    <input type="text" readonly="readonly" class="form-control" id="birthday" name="birthday" value="<fmt:formatDate value="${userInfo.birthday}" pattern="yyyy-MM-dd"/>" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-lg-2 control-label">家庭住址:</label>
                <div class="col-lg-9">
                    <textarea class="form-control" id="address" name="address" maxlength="225">${userInfo.address}</textarea>
                </div>
            </div>
        </form>
    </div>
</div>
<script type="text/javascript" src="${contextPath}/static/assets/js/date-time/bootstrap-datepicker.js"></script>
<script type="text/javascript" src="${contextPath}/static/assets/js/date-time/bootstrap-datepicker.zh-CN.js"></script>
<script type="text/javascript">
function selectWard(){
    var ajaxSelectUrl = contextPath + '/manage/ordering/ward/select';
    showSelectDlg("选择病房",ajaxSelectUrl,["table-data1"],setSelectValue);
}
function setSelectValue(obj){
    $("#wardId").val(obj[0].id);
    $("#wardName").val(obj[0].name);
}
jQuery(function($) {
    $("#birthday").datepicker({//日期选择器
        language : "zh-CN",
        format : 'yyyy-mm-dd',
        forceParse : true,
        pickTime : false,
        todayBtn : false,
        autoclose : true,
        minView : '2',
        forceParse : false
    });
    
    $('#formDlg').validate({
        errorElement : 'span',
        errorClass : 'help-block',
        focusCleanup : false,
        focusInvalid : false,
        onsubmit : false,
        rules : {
            "user.mobile":{required:true,maxlength:11,minlength:11},
            "wardName":{required:true}
        },
        messages : {
            "user.mobile" : '请输入正确的手机号',
            "wardName" : '请选择所属病房',
        },
        highlight : function(e) {
            $(e).closest('.form-group').removeClass('has-info').addClass('has-error');
        },
        success : function(e) {
            $(e).closest('.form-group').removeClass('has-error').addClass('has-success');
            $(e).remove();
        },
    });
});
</script>